package examples;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.util.*;

import com.hyperrealm.kiwi.ui.*;
import com.hyperrealm.kiwi.ui.graph.*;
import com.hyperrealm.kiwi.ui.model.*;
import com.hyperrealm.kiwi.util.*;
import com.hyperrealm.kiwi.ui.dialog.*;

public class GraphTest extends KFrame
{
  private PieChart3D pie_chart;
  private ClusteredBarChart3D hbar_chart;
  private ClusteredBarChart3D vbar_chart;
  private StackedBarChart3D shbar_chart;
  private StackedBarChart3D svbar_chart;
  private LineChart line_chart;
  private Chart chart;
  
  public static void main(String args[])
  {
    GraphTest gt = new GraphTest();
    gt.setVisible(true);
  }

  public GraphTest()
  {
    super("Charts");

    chart = new Chart();
    chart.setTickInterval(10.0);
    // chart.setPrecision(0);
    chart.addValue(new ChartValue("apples", "Apples", Color.red));
    chart.addValue(new ChartValue("oranges", "Oranges", Color.orange));
    chart.addValue(new ChartValue("lemons", "Lemons", Color.yellow));
    chart.addValue(new ChartValue("limes", "Limes", Color.green));

    ChartModel model = new DefaultChartModel(chart);

    BasicDataSample ds1 = new BasicDataSample();
    ds1.putValue("apples", 20.0);
    ds1.putValue("oranges", 1.0);
    ds1.putValue("lemons", 15.0);
    ds1.putValue("limes", 25.0);

    model.addDataSample(ds1);

    BasicDataSample ds2 = new BasicDataSample();
    ds2.putValue("apples", 5.0);
    ds2.putValue("oranges", 11.0);
    ds2.putValue("lemons", 32.0);
    ds2.putValue("limes", 15.0);

    model.addDataSample(ds2);

    BasicDataSample ds3 = new BasicDataSample();
    ds3.putValue("apples", 8.0);
    ds3.putValue("oranges", 11.0);
    ds3.putValue("lemons", 29.0);
    ds3.putValue("limes", 15.0);

    model.addDataSample(ds3);

    BasicDataSample ds4 = new BasicDataSample();
    ds4.putValue("apples", 2.0);
    ds4.putValue("oranges", 22.0);
    ds4.putValue("lemons", 42.0);
    ds4.putValue("limes", 18.0);

    model.addDataSample(ds4);

    BasicDataSample ds5 = new BasicDataSample();
    ds5.putValue("apples", 14.0);
    ds5.putValue("oranges", 14.0);
    ds5.putValue("lemons", 32.0);
    ds5.putValue("limes", 10.0);

    model.addDataSample(ds5);
    
    
    

    KPanel p = getMainContainer();

    p.setLayout(new BorderLayout(5, 5));
    p.setBorder(KiwiUtils.defaultBorder);

    JTabbedPane tabs = new JTabbedPane();

    p.add("South", new ChartLegend(chart));
    
    p.add("Center", tabs);

    pie_chart = new PieChart3D(chart);
    pie_chart.setModel(model);
    tabs.addTab("Pie Chart", pie_chart);


    vbar_chart = new ClusteredBarChart3D(chart, BarChart3D.VERTICAL);
    vbar_chart.setModel(model);
    vbar_chart.setPreferredSize(new Dimension(400, 400));
    tabs.addTab("Vertical Clustered Bar Chart", vbar_chart);

    svbar_chart = new StackedBarChart3D(chart, BarChart3D.VERTICAL);
    svbar_chart.setModel(model);
    tabs.addTab("Vertical Stacked Bar Chart", svbar_chart);

    hbar_chart = new ClusteredBarChart3D(chart, BarChart3D.HORIZONTAL);
    hbar_chart.setModel(model);
    tabs.addTab("Horizontal Clustered Bar Chart", hbar_chart);

    shbar_chart = new StackedBarChart3D(chart, BarChart3D.HORIZONTAL);
    shbar_chart.setPreferredSize(new Dimension(400, 400));
    shbar_chart.setModel(model);
    tabs.addTab("Horizontal Stacked Bar Chart", shbar_chart);

    line_chart = new LineChart(chart);
    line_chart.setModel(model);
    tabs.addTab("Line Chart", line_chart);
  
    pack();
  }

}
